package com.samphanie.auiu.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.samphanie.auiu.admin.service.ISysMenuResourceService;
import com.samphanie.auiu.mbg.mapper.SysMenuResourceMapper;
import com.samphanie.auiu.mbg.model.SysMenuResource;
import com.samphanie.auiu.mbg.utils.PageUtils;
import lombok.RequiredArgsConstructor;
import lombok.val;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 角色菜单关联Service业务层处理
 *
 * @author zsy
 * @date 2021-05-18
 */
@Service
@RequiredArgsConstructor
public class SysMenuResourceServiceImpl extends ServiceImpl<SysMenuResourceMapper, SysMenuResource> implements ISysMenuResourceService {

    @Override
    public PageUtils listPage(Map<String, Object> query) {
        PageUtils.startPage(query);
        val list = list();
        return new PageUtils(list);
    }

    @Override
    public List<SysMenuResource> listByMenuId(Long menuId) {
        return list(new LambdaQueryWrapper<SysMenuResource>().eq(SysMenuResource::getMenuId, menuId));
    }

    @Override
    public void deleteByMenuId(Long menuId) {
        baseMapper.delete(new LambdaQueryWrapper<SysMenuResource>().eq(SysMenuResource::getMenuId, menuId));
    }
}
